/**
 * Created by changshuiwang on 2016/7/29.
 */
$(function(){
    $(".add-teacher").click(function(){
        layer.open({
            type: 2,
            title: '添加教师',
            area: ['60%', '80%'],
            content: '/tea/add',
            /*            end : function(){ //层彻底关闭后执行的回调
             window.location.reload();
             }*/
        });
    });
    $(".add-teacher").submit(function(){
        var data=$(this).serialize();
        //alert(data);
        $.ajax({
            url:"/tea/add",
            data:data,
            type:"POST",
            dataType:'json',
            success:function(msg){
                if(msg.status=="success"){
                    alert("添加成功");
                    window.top.location.reload();
                }else{
                    alert(msg.error);
                }
            }
        })
        return false;
    });
    $(".glyphicon-trash").click(function(){
        if(confirm("确认删除么？")){
            var id=$(this).attr('id');
            $.ajax({
                url:"/tea/delete?id="+id,
                dataType:"json",
                success:function(msg){
                    if(msg.status=="success"){
                        alert("删除成功");
                        window.location.reload();
                    }else{
                        alert(msg.error);
                    }
                }
            });
        }
    });
    $(".validate").click(function(){
        $(this).attr('src','/site/img?'+Date.parse(new Date()));
    });
})